//
//  TongYongDeCellTableViewCell.m
//  DongChiDaChiProject1
//
//  Created by lanou3g on 15/10/29.
//  Copyright © 2015年 com.lanou3g. All rights reserved.
//

#import "TongYongDeCellTableViewCell.h"

@implementation TongYongDeCellTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addView];
    }
    return self;
}

// 构建视图
- (void)addView
{
    // 白色大背景
    self.whiteBackgroudView = [[UIView alloc] initWithFrame:CGRectMake(10 * kWidthFitParameter, 5 * kHeightFitParameter, 355 *kWidthFitParameter, 160 * kHeightFitParameter)];
    self.whiteBackgroudView.layer.cornerRadius = 5 * kWidthFitParameter;
    self.whiteBackgroudView.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:_whiteBackgroudView];
    
    // 图片
    self.smallPictureImage = [[UIImageView alloc] initWithFrame:CGRectMake(10 * kWidthFitParameter, 10 * kWidthFitParameter, 135 * kWidthFitParameter, 140 * kWidthFitParameter)];
    self.smallPictureImage.backgroundColor = [UIColor redColor];
    [self.whiteBackgroudView addSubview:_smallPictureImage];
    
    // 标题
    self.myTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.smallPictureImage.right + 5 * kWidthFitParameter,self.smallPictureImage.top , 150 * kWidthFitParameter, 50 * kHeightFitParameter)];
    self.myTitleLabel.font = [UIFont systemFontOfSize:20 * kWidthFitParameter];
    self.myTitleLabel.numberOfLines = 0;
   // self.myTitleLabel.backgroundColor = [UIColor redColor];
    [self.whiteBackgroudView addSubview:_myTitleLabel];
    
    // 人群
    self.fitLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.myTitleLabel.left, self.myTitleLabel.bottom + 30 * kHeightFitParameter, 150 * kWidthFitParameter, 50 * kHeightFitParameter)];
   // self.fitLabel.backgroundColor = [UIColor redColor];
    self.fitLabel.numberOfLines = 0;
    self.fitLabel.font = [UIFont systemFontOfSize:15 * kWidthFitParameter];
    [self.whiteBackgroudView addSubview:_fitLabel];
    
    // 影响
    self.effectLabel = [[UILabel alloc] initWithFrame:CGRectMake(self.myTitleLabel.right + 5 * kWidthFitParameter, self.myTitleLabel.top, 40 * kWidthFitParameter, 140 * kHeightFitParameter)];
    self.effectLabel.backgroundColor = [UIColor colorWithHue:0.5 saturation:1 brightness:1 alpha:0.05];
    self.effectLabel.numberOfLines = 0;
    self.effectLabel.font = [UIFont systemFontOfSize:20 * kWidthFitParameter];
    [self.whiteBackgroudView addSubview:_effectLabel];
    
    
}

#pragma mark - 靓汤
- (void)setQianTangModel:(QiangTangModel *)qianTangModel
{
    [self.smallPictureImage sd_setImageWithURL:[NSURL URLWithString:qianTangModel.thumb] placeholderImage:[UIImage imageNamed:@"placehoder.jpg"]];
    self.myTitleLabel.text = qianTangModel.title;
    self.effectLabel.text = qianTangModel.effect;
    self.fitLabel.text = qianTangModel.age;
}

#pragma mark - 特色小吃
- (void)setTeSeXiaoChiModel:(TeSeXiaoChiModel *)teSeXiaoChiModel
{
    [self.smallPictureImage sd_setImageWithURL:[NSURL URLWithString:teSeXiaoChiModel.thumb] placeholderImage:[UIImage imageNamed:@"placehoder.jpg"]];
    self.myTitleLabel.text = teSeXiaoChiModel.title;
    self.effectLabel.text = teSeXiaoChiModel.effect;
    self.fitLabel.text = teSeXiaoChiModel.age;
}

#pragma mark - 凉菜
- (void)setLiangCaiModel:(LiangCaiModel *)liangCaiModel
{
    [self.smallPictureImage sd_setImageWithURL:[NSURL URLWithString:liangCaiModel.thumb] placeholderImage:[UIImage imageNamed:@"placehoder.jpg"]];
    self.myTitleLabel.text = liangCaiModel.title;
    if (liangCaiModel.effect.length == 0) {
        switch (arc4random() % 3) {
            case 0:
                self.effectLabel.text = @"健脾开胃";
                break;
                case 1:
                self.effectLabel.text = @"美容养颜";
                case 2:
                self.effectLabel.text = @"瘦身减肥";
            default:
                break;
        }
       
    } else {
          self.effectLabel.text = liangCaiModel.effect;
    }
  
    self.fitLabel.text = liangCaiModel.age;
}

#pragma mark - 时尚饮品
- (void)setShiShangYinPinModel:(ShiShangYinPinModel *)shiShangYinPinModel
{
    [self.smallPictureImage sd_setImageWithURL:[NSURL URLWithString:shiShangYinPinModel.thumb] placeholderImage:[UIImage imageNamed:@"placehoder.jpg"]];
    self.myTitleLabel.text = shiShangYinPinModel.title;
    self.effectLabel.text = shiShangYinPinModel.effect;
    self.fitLabel.text = shiShangYinPinModel.age;
}

#pragma mark - 甜品
- (void)setTianPinModel:(TianPinModel *)tianPinModel
{
    [self.smallPictureImage sd_setImageWithURL:[NSURL URLWithString:tianPinModel.thumb] placeholderImage:[UIImage imageNamed:@"placehoder.jpg"]];
    self.myTitleLabel.text = tianPinModel.title;
    self.effectLabel.text = tianPinModel.effect;
    self.fitLabel.text = tianPinModel.age;
}

#pragma mark - 食疗药膳
- (void)setShiLiaoYaoShanModel:(ShiLiaoYaoShanModel *)shiLiaoYaoShanModel
{
    [self.smallPictureImage sd_setImageWithURL:[NSURL URLWithString:shiLiaoYaoShanModel.thumb] placeholderImage:[UIImage imageNamed:@"placehoder.jpg"]];
    self.myTitleLabel.text = shiLiaoYaoShanModel.title;
    self.effectLabel.text = shiLiaoYaoShanModel.effect;
    self.fitLabel.text = shiLiaoYaoShanModel.age;
}

#pragma mark - 美粥
- (void)setMeiZhouModel:(MeiZhouModel *)meiZhouModel
{
    [self.smallPictureImage sd_setImageWithURL:[NSURL URLWithString:meiZhouModel.thumb] placeholderImage:[UIImage imageNamed:@"placehoder.jpg"]];
    self.myTitleLabel.text = meiZhouModel.title;
    if (meiZhouModel.effect.length == 0) {
        switch (arc4random() % 3) {
            case 0:
                self.effectLabel.text = @"健脾开胃";
                break;
            case 1:
                self.effectLabel.text = @"美容养颜";
            case 2:
                self.effectLabel.text = @"瘦身减肥";
            default:
                break;
        }
        
    } else {
        self.effectLabel.text = meiZhouModel.effect;
    }
    self.fitLabel.text = meiZhouModel.age;
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}



@end
